'use strict';

/**
 * @ngdoc filter
 * @name htmsMobileApp.filter:getEntBaseInfoBdztByCode
 * @function
 * @description
 * # getEntBaseInfoBdztByCode 将企业基本信息的表单状态(bdzt)的代码转成中文
 * Filter in the htmsMobileApp.
 */
angular.module('htmsMobileApp')
  .filter('getEntBaseInfoBdztByCode', function () {
    return function (input) {
      switch (input){
        case 0 : return "未上报";break;
        case 1 : return "待核查";break;
        case 2 : return "待审核";break;
        case 3 : return "审核通过";break;
        case 4 : return "审核未通过";break;
        case 5 : return "申请重新指定监管部门";break;
        default : return "";
      }
    };
  }).filter('getQyjb',function(){
    return function(input){
      if(input != null && input != undefined && input != ''){
        return input + "级,";
      }else{
        return "";
      }
    }
  }).filter("toUrlString",function(){
    return function(searchObj){
      var url = searchObj.apiUrl;
      var page = searchObj.page;
      var size = searchObj.pageSize;
      var sortType = searchObj.sortType;
      var search = searchObj.search;
      var flag = false;
      if(url != undefined){
        if(page != undefined || size != undefined || search != undefined){
          url += "?";
          if(page != undefined){
            url += "page=";
            url += page;
            flag = true;
          }
          if(size != undefined){
            if(flag == true){
              url += "&";
            }
            url += "page.size=";
            url += size;
            flag = true;
          }
          if(sortType != undefined){
            if(flag == true){
              url += "&";
            }
            url += "sortType=";
            url += sortType;
            flag = true;
          }
          if(search != undefined){
            if(flag == true){
              url += "&";
            }
            if(search.length != undefined&&search.length >0){
              for(var i = 0;i < search.length;i++){
                url += search[i].key;
                url += "=";
                url += search[i].value;
                if(i != search.length - 1){
                  url += "&";
                }
              }
            }
          }
        }
      }
      return url;
    }
  }).filter("subYhms",function(subStringListTitleLength){
    return function(yhms) {
      if((yhms+"").length > subStringListTitleLength.cn_length){
        return yhms.substring(0,subStringListTitleLength.cn_length)+"...";
      }else {
        return yhms;
      }
    }
  }).filter("getYinhuangZgztByCode",function(){
    return function (input) {
      switch (input){
        case 1 : return "未整改";break;
        case 2 : return "整改中";break;
        case 3 : return "已整改";break;
        default : return "";
      }
    };
  }).filter("getYinhuangHcztByCode",function(){
    return function (input) {
      switch (input){
        case 0 : return "未核查";break;
        case 1 : return "已核查";break;
        default : return "";
      }
    };
  }).filter("getYinhuangFcztByCode",function(){
    return function (input) {
      switch (input){
        case 0 : return "未复查";break;
        case 1 : return "已复查";break;
        default : return "";
      }
    };
  });
